<template>
    <div id="deta">
        <headernav></headernav>
        <!-- 循环 -->
        <div class="HomePage-bottom zinde">
            
            <div class="HomeLive-title">
                <div class="HomeLive-titleLive">全部直播</div>
                <div class="HomeLive-titleNum">
                    <span>当前</span>
                    <span class="HomeLive-titleNumText mark">{{num}}</span>
                    <span>个直播</span>
                    <span class="HomeLive-titleNumIcon"></span>
                </div>
            </div>

            <!-- <div v-infinite-scroll="loadMore" :infinite-scroll-disabled="loading" infinite-scroll-distance="10">
                <div class="NormalRoomItem" v-for="(item,index) in arr" :key="index">
                    <div class="NormalRoomItem-show" @click="detaile(item.rid)">
                        <div class="NormalRoomItem-showImg"><img :src="item.roomSrc" alt=""></div>
                        <div class="NormalRoomItem-showHot">{{item.hn}}</div>
                        <div class="NormalRoomItem-showAnchor">{{item.nickname}}</div>
                    </div>
                    <div class="NormalRoomItem-title">{{item.roomName}}</div>
                </div>
            </div> -->

        </div>
        <div class="HomeLive-content" @touchmove.prevent v-infinite-scroll="loadMore"
            :infinite-scroll-disabled="loading" infinite-scroll-distance="20">
            <div class="NormalRoomItem" v-for="(item,index) in arr2" :key="index">
                <div class="NormalRoomItem-show" @click="detaile(item.rid)">
                    <div class="NormalRoomItem-showImg"><img :src="item.roomSrc" alt=""></div>
                    <div class="NormalRoomItem-showHot">{{item.hn}}</div>
                    <div class="NormalRoomItem-showAnchor">{{item.nickname}}</div>
                </div>
                <div class="NormalRoomItem-title">{{item.roomName}}</div>
            </div>
        </div>
        <div v-if="show" class="diamonds">拼命加载...</div>
    </div>
</template>
<script>
    import headernav from '@/components/nav'

    import { InfiniteScroll } from 'mint-ui';
    export default {
        name: "deta",
        components: {
            headernav,
        },
        data() {
            return {
                num: '',
                id: [],
                arr: [],
                list: [1, 2, 3, 54, 45, 65, 7,],
                loading: false,
                int: 0,
                show: false,
                arr2: [],
                Sne: [],
                res: []
            }
        },
        created() {
            console.log(this.list)
            this.id = this.$route.query.id
            this.id = this.$route.query.Sne
            if (this.id == undefined) {
                this.id = this.$route.query.id
            }
            this.get(0)
            this.getData(this.id)
            // console.log(this.arr2)
            // 取出路由
               this.arr = this.$router.options.routes
            console.log(this.arr)
        },
        methods: {
            getData(id) {
                this.$http.get(`/api/room/list?page=1&type=${id}`).then(res => {
                    this.arr = res.data.data.list
                    this.num = res.data.data.cate2Id
                    console.log(res)
                })
            },
            detaile(rid) {
                this.$router.push({
                    path: '/detlete',
                    query: {
                        rid: rid
                    }
                })
            },
            get() {
                this.$http.get(`/api/room/list?page=${this.int}&type=${this.id}`).then(res => {
                    this.res = res.data.data.pageCount
                    for (var i = 0; i < 8; i++) {
                        if (res.data.data.list[i] != undefined) {
                            this.arr2.push(res.data.data.list[i])
                            this.arr2.slice(8)
                        }
                    }
                    this.arr2.slice(8)
                    this.show = false
                })
            },
            // 下拉加载
            loadMore() {
                // console.log(this.int)
                if (this.int < this.res) {
                    this.int++
                    this.get()
                    this.show = true
                }

            },
        }
    }
</script>
<style scoped>
    body {
        overflow: hidden;
    }

    .deta {
        overflow-y: hidden
    }

    .red {
        color: #000;
    }

    .zinde:nth-child(1) {
        margin-top: 80px;
    }

    .img {
        width: 100%;
        height: 180px;
    }

    .swiper-container .swiper-slide {
        height: 20px;
        color: #666;
        padding: 5px;
        line-height: 20px;
    }

    .HomePage-bottom {
        width: 100%;
        overflow-x: hidden;
        overflow-y: auto;
        margin-top: 88px;
    }

    .diamonds {
        height: 50px;
        width: 100%;
        background: #fff;
        line-height: 50px;
        font-size: 12px;
        margin: 0 auto;;
    }

    .HomePage-bottom2:nth-child(1) {
        margin-top: 400px !important
    }

    .HomeLive {
        margin-top: 10px;
        width: 100%;
        background: #fff;
    }

    .HomeLive-title {
        display: flex;
        justify-content: space-between;
        justify-content: space-between;
        box-align: center;
        align-items: center;
        box-sizing: border-box;
        padding: 0 5px;
        width: 100%;
        height: 42px;
    }

    .HomeLive-titleLive {
        padding-left: 30px;
        height: 100%;
        line-height: 42px;
        color: #333;
        font-size: 15px;
        background: url(https://shark2.douyucdn.cn/front-publish/m-douyu-v3-master/assets/images/icon-live_88adc06.png) no-repeat;
        background-size: 20px 12px;
        background-position: 0;
    }

    .HomeLive-titleNum {
        font-size: 13px;
        color: #666;
        display: flex;
        align-items: center;
        height: 100%;
        line-height: 42px;
    }

    .mark {
        color: #f70
    }

    .HomeLive-titleNumIcon {
        display: block;
        margin-left: 5px;
        width: 13px;
        height: 13px;
        background: url(https://shark2.douyucdn.cn/front-publish/m-douyu-v3-master/assets/images/icon-more_6c08756.png) no-repeat;
        -webkit-background-size: 100% 100%;
        -moz-background-size: 100% 100%;
        background-size: 100% 100%;
    }

    /* 直播 */
    .HomeLive-content {
        box-sizing: border-box;
        padding-left: 4px;
        width: 100%;
        overflow: hidden;
    }

    .NormalRoomItem {
        color: #333;
        float: left;
        box-sizing: border-box;
        padding: 0 5px 5px 0;
        width: 50%;
    }

    .NormalRoomItem-show {
        color: #fff;
        position: relative;
        border-radius: 4px;
        width: 100%;
        overflow: hidden;
        background: url(https://shark2.douyucdn.cn/front-publish/m-douyu-v3-master/assets/images/list-item-def-thumb_b10bbe8.png) no-repeat;
        background-size: 100% 100%;
    }

    .NormalRoomItem-showImg {
        -moz-border-radius: 4px;
        border-radius: 4px;
        width: 100%;
        height: 100%;
    }

    .NormalRoomItem-showHot {
        position: absolute;
        top: 0;
        left: 0;
        z-index: 10;
        display: flex;
        justify-content: flex-end;
        align-items: center;
        box-sizing: border-box;
        padding-right: 5px;
        width: 100%;
        height: 18px;
        background: url(https://shark2.douyucdn.cn/front-publish/m-douyu-v3-master/assets/images/bg-shadow_e60f214.png) no-repeat;
        background-size: 100% 100%;
        border-radius: 4px 4px 0 0;
    }

    .NormalRoomItem-showAnchor {
        position: absolute;
        left: 0;
        bottom: 0;
        z-index: 10;
        display: flex;
        justify-content: flex-start;
        align-items: center;
        box-sizing: border-box;
        padding: 0 5px;
        border-radius: 0 0 4px 4px;
        width: 100%;
        height: 18px;
        overflow: hidden;
        background: linear-gradient(transparent, rgba(0, 0, 0, .8));
    }

    .NormalRoomItem-showImg img {
        -webkit-border-radius: 4px;
        -moz-border-radius: 4px;
        border-radius: 4px;
        width: 100%;
        height: 100%;
    }

    .NormalRoomItem-title {
        width: 100%;
        height: 27px;
        line-height: 27px;
        font-size: 12px;
        color: #333;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
</style>